freecivfandomcom-20200223-history
Editing Units
This page partially describes the contents of a ruleset collection. It is intended as developer reference and for people wanting to create/compile alternative rulesets for Freeciv. The anatomy of a units ruleset file The units.ruleset file contains all the information about unit types in the game. In addition to unit type entries there is some generic information about how units gain veterancy and how it affects them. Starting from Freeciv version 2.2 there are also unit class entries. Each unit type belongs to some unit class. Configurable Unit Type Flags Configurable Unit Type Flags are available starting from version 2.2 flags ; Names for custom unit type flags. names = "Airbase" ; Airbase - can build airbases. See airbase definition in terrain.ruleset This is list of custom unit type flags this ruleset uses. Custom unit type flags have no internal meaning to Freeciv, but ruleset can give them to units and have unit with such flag as requirement for effects or base building. Default ruleset has one such flag, Airbase. Workers and Engineers have Airbase flag and building Airbase requires it. Veteran System Veteran system entries are quite well documented in default ruleset. Note that individual unit types can have "NoVeteran" flag preventing it from becoming veteran no matter what generic veteran system definitions say. In default ruleset Settlers, Workers and Engineers all have "NoVeteran" flag, so changing veteran_work_raise_chance affects nothing. Unit Classes Unit classes are new concept in version 2.2 There can be maximum of 32 different unit classes. Do not add them without proper consideration if separate class is really needed. Considering all the cross-referencing from other ruleset files, big number of different unit class can prove difficult to maintain. For example typical effects.ruleset has effects with UnitClass requirements. If you want same effect to affect several classes, you need to provide separate effect for each. unitclass_sea name = _("Sea") move_type = "Sea" min_speed = 2 hp_loss_pct = 0 hut_behavior = "Normal" flags = "TerrainSpeed", "DamageSlows" Possible values for move_type are "Land", "Sea", "Both" and "Air". The terrain.ruleset defines exact limitations where units of this class can move, but move_type must be compatible with that. "Land" units cannot move at any oceanic terrain. "Sea" units can move only at oceanic terrains. "Air" units still have some special rules that makes them different from "Both". In theory you can have "Both" units that terrain.ruleset restricts to land terrains only, but you should not do that. AI does not use "Both" units. In default ruleset, Helicopters are "Both" units. Some units are slowed down when damaged. No matter how much damage they have, speed never drops below min_speed. Neither do terrain slow units below min_speed. Some units lose hitpoints when ever they end turn and are not in city, native base, or transport. hp_loss_pct tells how many percents of units total hitpoints is lost each turn. In default ruleset helicopters have non-zero hp_loss_pct. hut_behavior controls what happens when unit enters tile with hut (minor tribe village). "Normal" means that hut disappears with random effect. "Nothing" means that nothing happens, hut even remains for other units to come. "Frighten" means that hut just disappear without any other effects. In default ruleset airplanes and missiles "Frighten" Unit Class Flags * TerrainSpeed - Unit is not moving at constant speed, but terrain affects it. This includes effects from roads and railroads. In default ruleset all but flying units have this flag. * TerrainDefense - Units gain defense bonus from terrain. * DamageSlows - Unit is slowed down when damaged. In default ruleset land and sea units have this flag and flying units do not. * CanOccupyCity - Units of this class can occupy empty enemy cities. Note that particular unit type must be also military unit in order to occupy cities. In default ruleset land units and helicopters have this flag. * Missile - Unit disappears after it has attacked even if it was victorious. In default ruleset missiles have this flag * RoadNative - Even if particular base terrain is listed as non-native for this unit class, tiles with road are still considered native. That is, units can move anywhere where is road. In default ruleset we have no such units as all land units can move at all land terrains anyway. Removed in 2.5 Add native_to unit classes to terrain.ruleset road definitions instead. * RiverNative - Even if particular base terrain is listed as non-native for this unit class, tiles with river are still considered native. That is, units can move anywhere where is river. * BuildAnywhere - Units can be built even if city is located in non-native terrain for unit. In default ruleset land units have this flag so theoretical ocean cities can build them. Most definitely sea units do not have this flag. * Unreachable - By default other units cannot attack units of this class. Only those unit types listing this class in its targets can attack. In default ruleset airplanes and missiles have this flag and Fighters list them as targets. * CollectRansom - When unit of this class kills lone barbarian leader, player gains money. In default ruleset land units and helicopters have this flag. * ZOC - Units of this class are subject to Zone of Control rules. There is also unit type flag IgZOC that can be used to override this. In default ruleset land units class has this flag, but some individual unit types override it with IgZOC. * CanFortify - Units of this class can fortify in land squares. In default ruleset land units have this flag, flying units cannot fortify even when over land. * CanPillage - Units of this class can destroy tile improvements. In default ruleset land units have this flag. * DoesntOccupyTile - Even if enemy unit of this class is on tile, cities can still work it. In default ruleset air and missile units have this flag. * AttackNonNative - New in 2.5 Unit can attack units on non-native tiles. Unit type flag "Only_Native_Attack" can override this. * AttFromNonNative - New in 2.5 Unit can attack from non-native tile. Unit can be in such a tile in transport or in city. In default ruleset sea units have this flag so they can attack out from harbour cities. Unit type flag Marines works the same way, so use it if you want only some units of the class to be able to attack from non-native tiles. Unit Types unit_warriors name = _("Warriors") class = "Land" tech_req = "None" obsolete_by = "Pikemen" graphic = "u.warriors" graphic_alt = "-" sound_move = "m_warriors" sound_move_alt = "m_generic" sound_fight = "f_warriors" sound_fight_alt = "f_generic" build_cost = 10 pop_cost = 0 attack = 1 defense = 1 hitpoints = 10 firepower = 1 move_rate = 1 vision_radius_sq = 2 transport_cap = 0 fuel = 0 uk_happy = 1 uk_shield = 1 uk_food = 0 uk_gold = 0 flags = "" roles = "DefendOk", "FirstBuild" helptext = _("\ This unit may be built from the start of the game. It is the\ weakest unit.\ ") class refers to unit class this unit type belongs to. In 2.2 this is one of the classes defined earlier in the units.ruleset. In 2.1 this is one of the predefined classes: "Missile", "Land", "Sea", "Helicopter", "Air" or "Nuclear". tech_req is name of the tech that is required in order to build this unit. These are defined in Techs.ruleset. Special value "None" means that unit can be built without knowing any tech. impr_req required city improvement, name from buildings.ruleset obsolete_by is name of the another unit type to which this unit type upgrades to. convert_to is name of another unit type that this unit can be converted to. New in 2.3 convert_time is number of movement points it takes to convert to convert_to unit. New in 2.5 graphic is graphic tag for this unit. Tileset should provide graphics for matching this tag. graphic_alt is used as fallback tag if primary tag is not found from tileset. sound_move, sound_move_alt, sound_fight and sound_fight_alt Sound tags similar to graphic tags. build_cost is how much production is needed in order to build this unit. pop_cost is how much city size will shrink once unit is finished. In default ruleset only Settlers have population cost. attack is attack strength of unit. defense is defense strength of unit. hitpoints is number of hitpoints units of this type have when they are in full health. firepower is unit firepower. move_rate is unit speed. Here it is in full move points, not in 1/3 points. vision_radius_sq is how far unit sees. This is given as vision_radius_square in order to be able to see circular areas instead of square area. transport_cap tells how many other units this unit type can transport. cargo is new optional field in 2.2, applicable only for units that have transport_cap > 0. It is list of different unit classes this unit type can transport. In default ruleset Carrier has cargo = "Air", "Missile", "Helicopter". In 2.1 unit type flags define what other units unit can transport. fuel is number of turns that unit can live without refueling. Value 0 means that unit never needs to refuel. Value 1 means that unit needs to refuel every turn or to crash. Value other than zero should be given only to air units, it does not work correctly with other kind of units. uk_happy is how much unit causes unhappiness when aggressive. uk_shield is unit upkeep in shields / turn. uk_food is unit upkeep in food / turn. uk_gold is unit upkeep in gold / turn. city_size is new optional field in 2.2. Cities built by this unit will initially be of given size. Default is 1. targets is new optional field in 2.2. This is list of unit classes unit type can attack against even if those classes have "Unreachable" flag set. All unit types can attack classes without "Unreachable" flag even if class is not mentioned in targets. helptext is shown in inline help in addition to automatically generated help. Unit Type Flags Unit Type Roles Unit type can have multiple roles it fits in to. For starting units, first defined unit that fits the role related to a letter in "startunits" is placed (thus in classic ruleset for "w" you get Workers and not Engineers). The information below is for versions 2.6 and 3.0 except pieces in italic. "FirstBuild" - each newly founded city tries to build the best available unit with this role. A ruleset must have at least one. "Explorer" - starting Explorer unit type ("x") mandatory in a ruleset until v.2.5. In versions around 2.5 and earlier, homed explorers at their home cities are disbanded by AI when the dummy can't find a better use of it. "ExplorerStartUnit" (since v.2.6) - starting Explorer unit type ("x"). A ruleset must have at least one. "Hut" - if you know techs for no available "Hut_Tech" unit type, this unit appears when a hut gives you mercenaries (softcoded in default.lua) "HutTech" - when a hut produces a mercenary, it firstly looks for one of this role that the owner of the entered unit has a tech to build (softcoded in default.lua) "Partisan" - placed by place_partisans() routine (the partisan placing is mostly softcoded in default.lua but you would have to place another units by your own and can't make them fortified). Only one unit type may have this flag. "DefendOk" - starting defender unit ("d") until v.2.5. AI considers this type when gets a defender for a city. "DefendOkStartunit" (since v.2.6) marks "d" starting unit. "DefendGood" - starting good defending unit ("D") until v.2.5. AI considers this type when gets a defender for a city (twice more than "DefendOk") and as a bodyguard for a king. "DefendGoodStartunit" (since v.2.6) marks "D" starting unit. "AttackFastStartUnit" (until v.2.5: "AttackFast") - starting "a" unit. "AttackStrongStartUnit" (until v.2.5: "AttackStrong")- starting "A" unit. "FerryBoat" - A unit used for ferrying. A ruleset must have at least one. Must not have "Land" move type. May be placed as a starting unit as "f" but then it will not be generated if it has "Sea" movement type until v.2.5. AI uses ferries to bring colonists, caravans, spies or invasion forces to another continents. Cities may hang out a flag to beckon ferries or build their own ones for these means. "FerryStartunit" (since v.2.6) marks "f" starting unit (note, starting units are shifted to the closest possible tiles to the starting tile defined by random). "Barbarian" - random units of this role are generated as land barbarians since game start. A ruleset must have at least one if the barbarians are not disabled at load time. "BarbarianTech" - random units of this role are generated as land barbarians instead of starting ones since anybody knows the tech it requires. "BarbarianBoat" - sea barbarians may appear loaded into single this unit, tech knowledge is not important. Must have transport capacity of 2 or more and be able to transport barbarian leader and all sea barbarian types (the uprising amount is limited by minimum of barbarian abundance level value and the capacity). Must not have "Land" move type. A ruleset must have at least one if the barbarians are not disabled at load time. "BarbarianBuild" - barbarians can build these units in a city they control even if they don't have a tech for it. A ruleset must have at least one if the barbarians are not disabled at load time. "BarbarianBuildTech" - barbarians can build these units in a city they control if any player has learned the tech. (They can build units of those two roles only and their AI selects one with the best attack value, so expect Cannons going in hordes from conquered cities since one has got Metallurgy). "BarbarianLeader" - one such unit is generated at any barbarian uprising, if it is destroyed, the capturer may get a ransom. A ruleset must have at least one if the barbarians are not disabled at load time. "BarbarianSea" - random units of this role are generated as land barbarians since game start. A ruleset must have at least one if the barbarians are not disabled at load time. "BarbarianSeaTech" - random units of this role are generated as sea barbarians since any player has learned the tech. "CitiesStartunit" (until v.2.5: "Cities") - starting "c" unit. "Settlers" - may perform terrain alterations (build bases or roads, irrigate, mine or transform). Starting "w" unit and mandatory for a runleset until v.2.5. "WorkerStartunit" (since v.2.6) - starting "w" unit. "KingStartUnit" (v.2.5: "GameLoss") - startng gameloss unit ("k"). "DiplomatStartunit" - (until v.2.5: "Diplomat") - starting "s" unit. "Hunter" - non-bararian AI qualifies these units as hunters suitable for destroying enemy units (diplomatic, able to transport or gameloss), maybe using missiles, if our Horsemen have no missiles, just attack or go closer to the target if it looks worthy. For cities to consider building the units for this purpose, they must have either "Land" or "Sea" movement type. See also Category:Editing rulesets